home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7651 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: QUESTION:Random Numbers, etc
  5. Date: 24 Feb 1996 20:20:58 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4gnrva$m08@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe11.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Feb 24, 1996 19:39:56 in article <QUESTION:Random Numbers, etc>,
  15. 'garlans@usa.pipeline.com(White Shade)' wrote: 
  16.  
  17.  
  18. >Hi, I'm a bit new to C/C++ programming. I have Microsoft Visual C++ 1.52, 
  19. >and I'm trying to convert a few of my Basic programs to C so they'll run a
  20.  
  21. >lot faster. I need to know how to get a random number starting from one
  22. and 
  23. >ending at a certain number, like Basics a=int(rnd(1)*#)+1 or something... 
  24.  
  25. >Oh yeah, I can't check this group very often, so could you send replies to
  26.  
  27. >my e-mail address, GARLANS@USA.PIPELINE.COM ? Thanks...  
  28. Use the library function rand.  But, be aware that it returns only 
  29. a pseudo-random number (as does the random generator in VB).  
  30. Also, you need to initialize the random number generator, typically  
  31. at the begininning of your program.  Function srand is for that purpose. 
  32. Look in your on-line docs for details. 
  33.  
  34. -- 
  35. Pete Grant 
  36. Kalevi, Inc. 
  37. Software Engineering & development
  38.